package day0224;

import java.util.Arrays;

public class Demo03 {


    public static void main(String[] args) {
        // 函数式接口
//        Comparable
//        int[] arr = {2, 1, 3, 4, 1};
//
//        Arrays.sort(arr);
//        System.out.println(Arrays.toString(arr));

        Student[] stus = new Student[5];

        stus[0] = new Student("张三", 20, '男');
        stus[1] = new Student("李四", 20, '女');
        stus[2] = new Student("李四1", 21, '男');
        stus[3] = new Student("李四2", 10, '男');
        stus[4] = new Student("张三", 18, '女');

        // 对象数组的排序， Arrays.sort 要求对象实现 Comparable 接口
        Arrays.sort(stus);
//
        System.out.println(Arrays.toString(stus));
    }


    public void bubbleSort(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {

                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }
}
